<?php 

class CategoryController extends AuthController{
	private $db;
	public function __init()
	{
		$this->db=new CategoryModel;
	}
	//显示所有栏目
	public function index()
	{
		$data=$this->db->getlist();
		$this->assign('data',$data);
		$this->display('index.html');
	}
	//添加栏目
	public function add()
	{
		if (IS_POST) {
			if ($this->db->addCategory($_POST)) {
				$this->success('添加成功',__MODEL__.'&c=category');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display('add.html');
		}
	}

	//修改栏目
	public function edit()
	{
		if (IS_POST) {
			if ($this->db->editCategory($_POST)) {
				$this->success('修改成功',__CONTROLLER__);
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display('edit.html');
		}
	}

	//删除栏目
	public function delete()
	{
		if ($this->db->delCategory($_GET['cid'])) {
			$this->success('删除成功',__CONTROLLER__);
		}else{
			$this->error($this->db->error);
		}
	}


}


 ?>